﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class FaturaAdresi : System.Web.UI.Page
{
    protected void Page_PreRender(object sender, EventArgs e)
    {
        DilDegistir();
    }
    protected void DilDegistir()
    {

        if (Cookies.Dil == "TR")
        {
            lblTeslimatAdresi.InnerText = "YENİ FATURA ADRESİ";

            lblFaturaTipi.InnerText = "Fatura Tipi";
            lblBireysel.InnerText = "Bireysel Fatura (Şahıslar için)";
            lblKurumsal.InnerText = "Kurumsal Fatura (Şirketler için)";

            lblFirma.InnerText = "Firma";
            lblVergiDairesi.InnerText = "Vergi Dairesi";
            lblVergiNo.InnerText = "Vergi No";
            lblFaturaAdresi.InnerText = "Adres";
            lblFaturaPostaKodu.InnerText = "Posta Kodu";

            txtFirma.Attributes["placeholder"] = "Firma";
            txtVergiDairesi.Attributes["placeholder"] = "Vergi Dairesi";
            txtVergiNo.Attributes["placeholder"] = "Vergi No";
            txtAdres.Attributes["placeholder"] = "Adres";
            txtPostaKodu.Attributes["placeholder"] = "Posta Kodu";

            lblAdSoyad.InnerText = "Ad Soyad";
            lblAdres.InnerText = "Adres";
            lblPostaKodu.InnerText = "Posta Kodu";
            lblUlke.InnerText = "Ülke";
            lblSehir.InnerText = "Şehir";
            lblIlce.InnerText = "İlçe";
            lblSemt.InnerText = "Semt";
            lblTelefon.InnerText = "Telefon";
            lblTelefon2.InnerText = "Telefon 2";

            txtAdSoyad.Attributes["placeholder"] = "Ad Soyad";
            txtSahisAdres.Attributes["placeholder"] = "Adres";
            txtSahisPostaKodu.Attributes["placeholder"] = "Posta Kodu";
            txtSemt.Attributes["placeholder"] = "Semt";
            txtTelefon.Attributes["placeholder"] = "Telefon";
            txtTelefon2.Attributes["placeholder"] = "Telefon 2";

            chkAyniAdres.Text = "Fatura adresimle teslimat adresim aynı olsun. ";
            //btnAdresEkle.Value = "ADRESİ KAYDET VE DEVAM ET";
        }
        else
        {
            lblTeslimatAdresi.InnerText = "NEW INVIOICE ADDRESS";

            lblFaturaTipi.InnerText = "Invoice Type";
            lblBireysel.InnerText = "Personal Invoice";
            lblKurumsal.InnerText = "Invoice For Company";

            lblFirma.InnerText = "Company";
            lblVergiDairesi.InnerText = "Tax Office";
            lblVergiNo.InnerText = "Tax Number";
            lblFaturaAdresi.InnerText = "Address";
            lblFaturaPostaKodu.InnerText = "Postal Code";

            txtFirma.Attributes["placeholder"] = "Company";
            txtVergiDairesi.Attributes["placeholder"] = "Tax Office";
            txtVergiNo.Attributes["placeholder"] = "Tax Number";
            txtAdres.Attributes["placeholder"] = "Address";
            txtPostaKodu.Attributes["placeholder"] = "Postal Code";

            lblAdSoyad.InnerText = "Name";
            lblAdres.InnerText = "Address";
            lblPostaKodu.InnerText = "Postal Code";
            lblUlke.InnerText = "Country";
            lblSehir.InnerText = "City";
            lblIlce.InnerText = "County";
            lblSemt.InnerText = "District";
            lblTelefon.InnerText = "Phone";
            lblTelefon2.InnerText = "Phone 2";

            txtAdSoyad.Attributes["placeholder"] = "Name";
            txtSahisAdres.Attributes["placeholder"] = "Address";
            txtSahisPostaKodu.Attributes["placeholder"] = "Postal Code";
            txtSemt.Attributes["placeholder"] = "District";
            txtTelefon.Attributes["placeholder"] = "Phone";
            txtTelefon2.Attributes["placeholder"] = "Phone 2";

            chkAyniAdres.Text = "Invoice and shipping addresses should be same. ";
            //btnAdresEkle.Value = "SAVE THE ADDRESS AND CONTINUE";
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Sessions.SiparisFiyati == null)
                Response.Redirect(Page.GetRouteUrl("AnaSayfa", new { }));
        }
    }
    protected void btnKaydet_Click(object sender, EventArgs e)
    {
        int UlkeId = Convert.ToInt16(ulke.SelectedItem.Value);
        int SehirId = Convert.ToInt16(sehir.SelectedItem.Value);
        int IlceId = Convert.ToInt16(ilce.SelectedItem.Value);

        int AdresId = DataAccess.InsAdres(txtAdSoyad.Text, txtSahisAdres.InnerText, txtSahisPostaKodu.Text, "", txtFirma.Text, txtVergiDairesi.Text, txtVergiNo.Text, txtAdres.InnerText, txtPostaKodu.Text,
                                UlkeId, SehirId, IlceId, txtSemt.Text, txtTelefon.Text, txtTelefon2.Text);

        Sessions.FaturaAdresi = AdresId;
        Response.Redirect(Page.GetRouteUrl("KrediKarti", new { }));

    }
    protected void btnSil_Click(object sender, EventArgs e)
    {
        int AdresId = Convert.ToInt16(hidAdresId.Value);
        DataAccess.DelAdres(AdresId);
        listAdresler.DataBind();
    }

    protected void btnKullan_Click(object sender, EventArgs e)
    {
        Sessions.FaturaAdresi = Convert.ToInt16(hidAdresId.Value);
        Response.Redirect(Page.GetRouteUrl("KrediKarti", new { }));
    }
}